﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DA
{
    public class Branch_DAL : clsConnect
    {
        private clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable GetBranch()
        {
            return cls.GetData("sp_tb_Branch_Search");
        }
        public DataTable GetBranchDetail_Edit(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Branch_Detail_Edit", "@Branch_Id", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertBranch(ET.Branch_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Branch_Alias", data.Branch_Alias);
            cls.AddParameter("@Branch_Name", data.Branch_Name);
            cls.AddParameter("@Branch_Note", data.Branch_Note);
            cls.ExecuteNonQuery("sp_tb_Branch_Insert");
            return true;
        }
        public bool UpdateBranch(ET.Branch_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Branch_Id", data.Branch_Id);
            cls.AddParameter("@Branch_Alias", data.Branch_Alias);
            cls.AddParameter("@Branch_Name", data.Branch_Name);
            cls.AddParameter("@Branch_Note", data.Branch_Note);
            cls.ExecuteNonQuery("sp_tb_Branch_Update");
            return true;
        }
        public bool DeleteBranch(int id)
        {
            cls.Delete("sp_tb_Branch_Delete", "@Branch_Id", id);
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_tb_Branch_Search", "@KEYWORDS", keywords);
        }
        #endregion

        #region[ResetNumber]
        public bool ResetNumber(string table,int num = 0)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@TableName", table);
            cls.AddParameter("@NumberReset", num);
            cls.ExecuteNonQuery("sp_Reset_Number");
            return true;
        }
        #endregion
    }
}
